﻿namespace _4_NovaAdmin.Web.Core.Idempotency;

/// <summary>
/// 定义幂等性存储接口
/// </summary>
public interface IIdempotencyStore
{
    /// <summary>
    /// 创建幂等性记录
    /// </summary>
    /// <param name="idempotencyKey">幂等性键，用于唯一标识一个请求</param>
    /// <param name="response">与幂等性键关联的响应内容</param>
    /// <returns></returns>
    Task<bool> TryCreateRecordAsync(string idempotencyKey, string response);

    /// <summary>
    /// 根据幂等性键获取与之关联的响应内容
    /// </summary>
    /// <param name="idempotencyKey">幂等性键</param>
    /// <returns></returns>
    Task<string?> GetResponseAsync(string idempotencyKey);
}
